package com.stiove.whwh.Controller;


import com.stiove.whwh.service.AdminService;
import com.stiove.whwh.service.OrderService;
import com.stiove.whwh.service.TicketService;
import com.stiove.whwh.vo.Result;
import com.stiove.whwh.vo.params.TicketParams;
import com.stiove.whwh.vo.params.UserLoginParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.xml.ws.Action;

@RestController
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;

    @Autowired
    private TicketService ticketService;
    @Autowired
    private OrderService orderService;


    @PostMapping("/login")
    public Result login(@ModelAttribute UserLoginParams user){
        return adminService.adminLogin(user.getUsername(),user.getPassword());
    }


    @GetMapping("/test")
    public Result test(){
        return new Result(Result.SUCCESS,"ok",1);
    }


    @PostMapping("/ticket")
    public Result creatTicket(@ModelAttribute TicketParams ticketParams){
        return ticketService.creatTicket(ticketParams);
    }

    @GetMapping("/ticket")
    public Result getAdminTicket(@RequestParam int page){
        return ticketService.getAdminTicket(page);
    }

    @DeleteMapping("/ticket")
    public Result delTicket(@RequestParam int id){
        return ticketService.delTicket(id);
    }
    @GetMapping("/order")
    public Result getAdminOrder(@RequestParam int page){
        return orderService.getAdminOrder(page);
    }


}
